/**
 * 
 */
package cs437;

import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;

/**
 * @author braunja1
 *
 */
//Rank Window
public class RankWindow extends QWidget
{
	String name;
	Talent t;
	public RankWindow(Talent t, TalentHandler parent)
	{	setParent(parent);
		name = t.getName();	
		this.t = t;
	}
	
	private QRectF boundingRect = new QRectF(0, 0, 200, 100);
	public QRectF boundingRect()
	{
		return boundingRect;
	}
	
	/***************************************************** 
	 * Shape: This function is an interface function QT requires of QGraphicItems
	 * Shape defines the shape of the object; Used in collision detection
	 * Ours has a defined height and width
	 *****************************************************/
	QPainterPath shape = new QPainterPath();
	{
		shape.addRoundRect(boundingRect, 20);
	}
	
	public QPainterPath shape() {
		return shape;
	}
	
	
	/*****************************************************
	 * Paint: This function is an interface function QT requires of QGraphicItems
	 * Purpose: Draws the GraphicsItem on screen using a combination of Brushes, Pens and Pixmaps. 
	 *****************************************************/
	/*public void paint(QPainter painter, QStyleOptionGraphicsItem option,
	QWidget widget)
	{

		//Brush & Light Blue color for BG		
		QBrush brush = new QBrush(QColor.black);			
		if (!scene().collidingItems(this).isEmpty())
		{
			//brush.setColor(QColor.red);
		}			
		/****************************************************
		 * Drawing the Child Connection
		 * If the talent has a child, it draws an arrow from itself to the child
		 * This is done by subtracting the talent's tier from the child's tier # then multiplying that by the height.
		 * The child is always in the same x-position
		 * S
		 *****************************************************
		
		painter.fillPath(shape, brush);
		painter.drawPath(shape);		

		// Draw the Icon associated with this talent	
		painter.setPen(QColor.white);
		//Draw the Box that borders the ranks/ranksAchieved
		QRectF box = boundingRect;		
		QPainterPath pp = new QPainterPath();		
		pp.addRoundRect(box, 25);
		painter.fillPath(pp, brush);
		painter.drawPath(pp);
		painter.fillPath(shape, brush);
		painter.drawPath(shape);
		
		//Draw the rankAchieved/ranks
		painter.drawText(0, 0, 100, 15, 0, name);
		painter.drawText(new QPoint(0, 45), t.currentRank);
		QTextOption o = new QTextOption();
		o.setWrapMode(QTextOption.WrapMode.WordWrap);
		
	}*/
	 @Override
	    protected void paintEvent(QPaintEvent pe) {
	    	// TODO Auto-generated method stub
	    	super.paintEvent(pe);
	    	//Brush & Light Blue color for BG		
			QBrush brush = new QBrush(QColor.black);			

	    	QPainter p = new QPainter();
	    	p.begin(this);
			
			
			p.fillPath(shape, brush);
			p.drawPath(shape);		
			QPainterPath pp = new QPainterPath();		
			pp.addRoundRect(boundingRect, 25);
			// Draw the Icon associated with this talent	
			p.setPen(QColor.white);
	    	p.fillPath(pp, brush);
			p.drawPath(pp);
			p.fillPath(shape, brush);
			p.drawPath(shape);
			p.drawText(0, 0, 100, 15, 0, name);
			p.drawText(new QPoint(0, 45), t.currentRank);
			QTextOption o = new QTextOption();
			o.setWrapMode(QTextOption.WrapMode.WordWrap);
	    	
	    	p.setPen(QColor.darkYellow);
	    	QFont f = new QFont();
	    	f.setFamily("Trajan Pro");
	    	f.setPointSize(48);
	    	f.setBold(true);
	    	p.setFont(f);
	    	p.drawText(200, 550, "Select a Class");
	    	p.end();
	    }
}


